<template>
	<view class="my-userinfo">
		<!-- 头像区域 -->
		<view class="avatar">
			<image :src="userInfo.avatarUrl" mode=""></image>
			<text>{{userInfo.nickName }}</text>
		</view>
		<view class="contentbox">
			<!-- 第一个面板 -->
			<view class="one">
				<view class="one-item">
					<view class="num">8</view>
					<view class="name">收藏的店铺</view>
				</view>
				<view class="one-item">
					<view class="num">14</view>
					<view class="name">收藏的商品</view>
				</view>
				<view class="one-item">
					<view class="num">18</view>
					<view class="name">关注的商品</view>
				</view>
				<view class="one-item">
					<view class="num">84</view>
					<view class="name">足迹</view>
				</view>
			</view>
			<!-- 第二个面板 -->
			<view class="two">
				<view class="title">我的订单</view>
				<view class="twobox">
					<view class="two-item">
						<image src="../../static/my-icons/icon1.png" mode=""></image>
						<text>待付款</text>
					</view>
					<view class="two-item">
						<image src='../../static/my-icons/icon2.png' mode=""></image>
						<text>待收货</text>
					</view>
					<view class="two-item">
						<image src="../../static/my-icons/icon3.png" mode=""></image>
						<text>退款/退货</text>
					</view>
					<view class="two-item">
						<image src="../../static/my-icons/icon4.png" mode=""></image>
						<text>全部订单</text>
					</view>
				</view>
			</view>
			<!-- 第三个面板 -->
			<view class="three">
				<view class="three-item">
					<text>收货地址</text>
					<uni-icons type="right" size="20"></uni-icons>
				</view>
				<view class="three-item">
					<text>联系客服</text>
					<uni-icons type="right" size="20"></uni-icons>
				</view>
				<view @click="logout" class="three-item">
					<text>退出登录</text>
					<uni-icons type="right" size="20"></uni-icons>
				</view>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		name: "my-userinfo",
		data() {
			return {

			};
		},
		computed: {
			...mapState('user', ['userInfo'])
		},
		methods: {
			...mapMutations('user', {
				'mylogout': 'logout'
			}),
			async logout() {
				const res = await uni.showModal({
					title: '提示',
					content: '是否确定退出登录'
				})
				// 判断
				if (res[0] !== null) return uni.$showMsg()
				if (res[1].confirm) {
					// 点击的是确定
					// 退出登录
					this.mylogout()
					// 提示退出成功
					uni.showToast({
						title: '退出登录成功'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.my-userinfo {
		background-color: #f4f4f4;
		height: 100vh;

		.avatar {
			height: 400rpx;
			background-color: #eb4450;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			image {
				width: 160rpx;
				height: 160rpx;
				border-radius: 50%;
				border: 2px solid #fff;
			}

			text {
				color: #fff;
				margin-top: 20rpx;
			}
		}

		.contentbox {
			padding: 0 20rpx;
		}

		.one {
			margin-top: -20rpx;
			display: flex;
			background-color: #fff;
			border-radius: 10rpx;

			.one-item {
				height: 100rpx;
				flex: 1;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				font-size: 14px;
			}
		}

		.two {
			background-color: #fff;
			border-radius: 10rpx;
			margin-top: 20rpx;

			.title {
				line-height: 80rpx;
				border-bottom: 1px solid #f4f4f4;
				padding-left: 20rpx;
			}

			.twobox {
				padding: 20rpx 0;
				display: flex;

				.two-item {
					font-size: 14px;
					flex: 1;
					display: flex;
					flex-direction: column;
					align-items: center;

					image {
						width: 80rpx;
						height: 80rpx;
						margin-bottom: 10rpx;
					}
				}
			}
		}

		.three {
			background-color: #fff;
			border-radius: 10rpx;
			margin-top: 20rpx;

			.three-item {
				padding: 20rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
			}
		}
	}
</style>
